package com.monster.utils;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 时间格式花工具类
 *
 * @author kuang
 */
public class DateUtils {
    private DateUtils() {
    }

    private static final Map<String, DateTimeFormatter> formatters = new HashMap<>(10);
    public static final String DATE_TIME_MILLI_COMPACT = "yyyyMMddHHmmssSSS";

    static {
        formatters.put(DATE_TIME_MILLI_COMPACT, DateTimeFormatter.ofPattern(DATE_TIME_MILLI_COMPACT).withZone(ZoneId.systemDefault()));
    }

    /**
     * 获取默认时间
     *
     * @return 默认系统时间
     */
    public static String getSystemDefault() {
        return formatters.get(DATE_TIME_MILLI_COMPACT).format(new Date().toInstant());
    }
}
